package com.gl.rent;

import com.haixiaoke.saas.repository.core.AjaxResult;
import com.haixiaoke.saas.repository.core.BaseController;
import com.haixiaoke.saas.repository.core.page.TableDataInfo;
import com.haixiaoke.saas.repository.pojo.Decoration;
import com.haixiaoke.saas.repository.service.IDecorationService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 装修情况Controller
 *
 * @author zhiping
 * @date 2023-04-06
 */
@RestController
@RequestMapping("/house/decoration")
public class DecorationController extends BaseController {


    @Autowired
    private  IDecorationService decorationService;

    /**
     * 查询装修情况列表
     */
    // @PreAuthorize("@ss.hasPermi('base:decoration:list')")
    @GetMapping("/list")
    public TableDataInfo list(Decoration decoration) {
        startPage();
        List<Decoration> list = decorationService.selectDecorationList(decoration);
        return getDataTable(list);
    }

    /**
     * 获取装修情况详细信息
     */
    // @PreAuthorize("@ss.hasPermi('base:decoration:query')")
    @GetMapping(value = "/{decorationId}")
    public AjaxResult getInfo(@PathVariable("decorationId") Long decorationId) {
        return success(decorationService.selectDecorationByDecorationId(decorationId));
    }

    /**
     * 新增装修情况
     */
    // @PreAuthorize("@ss.hasPermi('base:decoration:add')")
    @PostMapping
    public AjaxResult add(@RequestBody Decoration decoration) {
        return toAjax(decorationService.insertDecoration(decoration));
    }

    /**
     * 修改装修情况
     */
    // @PreAuthorize("@ss.hasPermi('base:decoration:edit')")
    @PutMapping
    public AjaxResult edit(@RequestBody Decoration decoration) {
        return toAjax(decorationService.updateDecoration(decoration));
    }

    /**
     * 删除装修情况
     */
    // @PreAuthorize("@ss.hasPermi('base:decoration:remove')")
    @DeleteMapping("/{decorationIds}")
    public AjaxResult remove(@PathVariable Long[] decorationIds) {
        return toAjax(decorationService.deleteDecorationByDecorationIds(decorationIds));
    }
}
